package 洛谷;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class 求区间和_前缀和 {
	public static void main(String[] args) throws IOException {
		//前缀和
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n + 1];
		String[] s = br.readLine().split(" ");
		for (int i = 1; i <= n; i++) {
			a[i] = Integer.parseInt(s[i - 1]);
		}
		int[] dp = new int[n + 1];
		dp[1] = a[1];
		for (int i = 2; i <= n; i++) {
			dp[i] = dp[i - 1] + a[i];
		}
		int m = Integer.parseInt(br.readLine());
		for (int i = 0; i < m; i++) {
			String[] sp = br.readLine().split(" ");
			int l = Integer.parseInt(sp[0]);
			int r = Integer.parseInt(sp[1]);
			System.out.println(dp[r] - dp[l - 1]);
		}
	}
}
